<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var contents = document.getElementById("contents");
		if(contents.value == ""){
			alert("<fmt:message key='import.message.selectFile'/>");
			return false;
		}
		return true;
	}
	
	function back(){
		window.location.href = "./openCustomer.do";
		window.location.target = "main";
	}
	
	function downloadTemplate(){
		document.openBatchImportForm.action = "./openCustomer.do?action=downloadTemplate";
		document.openBatchImportForm.target = "main";
		document.openBatchImportForm.submit();
	}
	
	function importCustomer(){
		if(checkForm()){
			document.openBatchImportForm.action = "./openCustomer.do?action=batchImportCustomer";
			document.openBatchImportForm.target = "main";
			document.openBatchImportForm.submit();
			document.getElementById("importBtn").href = "#";//变为不可用
			document.getElementById("trImport").style.display = "block";
			document.getElementById("tableImportInfo").style.display = "none";
		}
	}
	
	function initPage(result){
		if(result == 1){
			alert("<fmt:message key='import.message.success'/>");
		}else if(result == 2){
			alert("<fmt:message key='import.message.emptyFile'/>");
		}else if(result == 3){
			alert("<fmt:message key='import.message.overSize'/>");
		}
		document.getElementById("importBtn").href = "javascript:importCustomer();";//变为可用
		document.getElementById("trImport").style.display = "none";
		document.getElementById("tableImportInfo").style.display = "block";
	}
-->
</script>
</head>
<body onload="initPage('${result}')">
<form name="openBatchImportForm" action="" method="post" enctype="multipart/form-data">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="3">
							公海批量导入
						</td>
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;"><fmt:message key='import.lable.fileName'/>
							<input id="contents" name="contents" type="file" size="50" value="${uploadFileForm.contents}"/>
							<a class="import" id="importBtn" name="importBtn" href="javascript:importCustomer();" target="main" hidefocus="true">导入</a>
							|
							导入格式：
							<a class="upload" href="javascript:downloadTemplate()" target="main" hidefocus="true">下载</a>
						</td>
						<td></td>
						<td valign="bottom" align="right" class="a_tools" style="padding-top: 4px;">
							<a class="back" href="javascript:back();" hidefocus="true">返回列表</a>&nbsp;&nbsp;
						</td>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">
							导入结果信息
						</td>
					</tr>
					<tr id="trImport" style="display: none;text-align: center;">
						<td class="" style="height: 50px;"><b><fmt:message key='import.message.importing'/></b></td>
					</tr>
					<tr>
						<td>
							<table class="table">
								<tr>
									<td valign="top">
										<div style="width:100%;height:420px;overflow-x: hidden;overflow-y: scroll;">
										<table id="tableImportInfo" class="table_style" style="display: block;">
											<tr>
												<td class="title" width="12%"><fmt:message key='import.lable.rowNum'/></td>
												<td class="title" width="12%"><fmt:message key='import.lable.result'/></td>
												<td class="title" width=""><fmt:message key='import.lable.failReason'/></td>
											</tr>
											<c:forEach var="log" items="${logs}">
											<c:choose>
												<c:when test="${log.reason == '2'}">
													<tr>
														<td>${log.id}</td>
														<td><fmt:message key='import.message.success'/></td>
														<td></td>
													</tr>
												</c:when>
												<c:otherwise>
													<tr style="color: red;">
														<td>${log.id}</td>
														<td><fmt:message key='import.message.fail'/></td>
														<td>
														<c:choose>
															<c:when test="${log.reason == '0'}"><fmt:message key='import.message.errorInfo'/></c:when>
															<c:when test="${log.reason == '1'}"><fmt:message key='import.message.repeat'/></c:when>
															<c:when test="${log.reason == '4'}">预测签约日期格式不正确</c:when>
															<c:when test="${log.reason == '5'}"><fmt:message key='import.message.notEmpty'/></c:when>
															<c:when test="${log.reason == '12'}">部门1为空</c:when>
															<c:when test="${log.reason == '13'}">生日1日期格式不正确</c:when>
															<c:when test="${log.reason == '22'}">部门2为空</c:when>
															<c:when test="${log.reason == '23'}">生日2日期格式不正确</c:when>
															<c:when test="${log.reason == '32'}">部门3为空</c:when>
															<c:when test="${log.reason == '33'}">生日3日期格式不正确</c:when>
															<c:otherwise></c:otherwise>
														</c:choose>
														</td>
													</tr>
												</c:otherwise>
											</c:choose>
											</c:forEach>
										</table>
										</div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>